package heap;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhengDp
 * @Date 2023/5/12 15:51
 * @Description 堆内存溢出 -Xmx8m
 */
public class Heap_Demo1 {
    public static void main(String[] args) {
        int i =0;
        try {
            List<String> list = new ArrayList<>();
            String a = "hello";
            while(true) {
                list.add(a);
                a = a+a;
                i++;
            }
        }catch (Exception e) {
        }finally {
            System.out.println(i);
        }
    }
}
